<?php
//办事处的数据列表
function json_banshichu($jsonstr,$idstr="editteble") {
	$table .="<table id=\"$idstr\" border=\"1\">
				  <tr>
				    <th scope=\"col\" width='70'>颜色</th>
				    <th scope=\"col\" width='70'>S</th>
				    <th scope=\"col\" width='70'>M</th>
				    <th scope=\"col\" width='70'>L</th>
				    <th scope=\"col\" width='70'>XL</th>
				    <th scope=\"col\" width='70'>XXL</th>
				    <th scope=\"col\" width='70'>3XL</th>
				  </tr>";
	$obj = json_decode($jsonstr);
	$munber=0;
	//print_r($obj);
	foreach ($obj->banshichu as $value) {
		$munber += (int)$value->s;
		$munber += (int)$value->m;
		$munber += (int)$value->l;
		$munber += (int)$value->xl;
		$munber += (int)$value->xxl;
		$munber += (int)$value->xxxl;
		
		$table .= "<tr height='24'>
				    <td>$value->yanse</td>
				    <td>$value->s</td>
				    <td>$value->m</td>
				    <td>$value->l</td>
				    <td>$value->xl</td>
				    <td>$value->xxl</td>
				    <td>$value->xxxl</td>
				  </tr>";
	}
	
	$table .= "</table>合计:$munber";
	return $table;
}
//将装箱数100/90转换为数组
function maxboxmunber($str) {
	$arr = array();
	$strarr=explode("/", $str);
	switch (count($strarr)){
		case 1;
		$arr['s']=$strarr[0];
		$arr['m']=$strarr[0];
		$arr['l']=$strarr[0];
		$arr['xl']=$strarr[0];
		$arr['xxl']=$strarr[0];
		$arr['xxxl']=$strarr[0];
		break;
		case 2;
		$arr['s']=$strarr[0];
		$arr['m']=$strarr[0];
		$arr['l']=$strarr[0];
		$arr['xl']=$strarr[1];
		$arr['xxl']=$strarr[1];
		$arr['xxxl']=$strarr[1];
		break;
		case 3;
		$arr['s']=$strarr[0];
		$arr['m']=$strarr[0];
		$arr['l']=$strarr[1];
		$arr['xl']=$strarr[1];
		$arr['xxl']=$strarr[2];
		$arr['xxxl']=$strarr[2];
		break;				
	};
	return $arr;
}

function boxlistarr_totrlist($arr) {
	$trlist="";
	foreach ($arr as $item) {
		if (count($item['listdata'])>1) {
			$listmunber =" rowspan='"+count($item['listdata'])+"'";
		}else {
			$listmunber ="";
		}	
		$trlist .= "<tr><td $listmunber>$item[boxmunber]</td>";
					    foreach ($item['listdata'] as $value) {
						$trlist .= "<td>$value[yanse]</td><td>$value[s]</td><td>$value[m]</td><td>$value[l]</td><td>$value[xl]</td><td>$value[xxl]</td>";
					    }
		$trlist .= 	"<td $listmunber></td><td $listmunber></td></tr>";
	}
	return $trlist;
}
//通过箱号得到箱数
function munbertoint($mun){
	$arr=explode("-", $mun);
	if ( count($arr) > 1 ) {
		return ($arr[1]-$arr[0]);
	}else {
		return 1;
	}
}